public class Mystery3 {
    public static void main(String[] args) {
        System.out.println(mystery3(3, 3));
        System.out.println(mystery3(5, 3));
        System.out.println(mystery3(2, 6));
        System.out.println(mystery3(12, 18));
        System.out.println(mystery3(30, 75));
    }

    public static int mystery3(int x, int y) {
        while (x != 0 && y != 0) {
            if (x < y) {
                y -= x;
            } else {
                x -= y;
            }
        }
        return x + y;
    }

}